package cn.snmp.mutual.nms.util;


public class SnmpUtilities {


    public static byte[] toBytes(String hexStr) {
        final byte mask = 127;
        byte[] bytes = new byte[0];
        if (hexStr != null) {
            hexStr = hexStr.toUpperCase();
            final int len = hexStr.length();
            bytes = new byte[len / 2];
            for (int sPos = 0, bPos = 0; sPos < len; sPos += 2, ++bPos) {
                final char a = hexStr.charAt(sPos);
                final char b = hexStr.charAt(sPos + 1);
                final int v1 = Character.digit(a, 16);
                final int v2 = Character.digit(b, 16);
                final int v3 = v1 * 16 + v2;
                bytes[bPos] = (byte) v3;
            }
        }
        return bytes;
    }

}
